//
//  ViewController.m
//  Sqlite_ThroughModelManagerDataBase
//
//  Created by Ager on 15/11/10.
//  Copyright © 2015年 Ager. All rights reserved.
//

#import "ViewController.h"
#import "AGDatabaseManager.h"
#import "Person.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    
    
    [[AGDatabaseManager shareAGDatabaseManager] creatTable:[Person class] tableName:@"person" keyName:@"age" primaryKey:@"PRIMARY KEY"];
    
    for (int i = 20; i  < 30 ; i++) {
        Person *per = [[Person alloc]init];
        per.name = @"Ager";
        per.age = i;
        per.score = 78;
        [[AGDatabaseManager shareAGDatabaseManager] insert:per tableName:@"person"];
    }
    
//    Person *per = [[Person alloc]init];
//    per.name = @"Arun";
//    per.age = 24;
//    per.score = 78;
////    [[AGDatabaseManager shareAGDatabaseManager]update:per tableName:@"person" where:@"age = 22"];
//    
//    [[AGDatabaseManager shareAGDatabaseManager] deleteTableName:@"person" where:@"age = 23"];
//    
//    
    NSArray *array = [[AGDatabaseManager shareAGDatabaseManager]select:[Person class] tableName:@"person" where:@"name = 'Ager'"];
    NSLog(@"%@",array);
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
